# -*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns
from django.conf.urls.defaults import include
from django.conf.urls.defaults import url

from django.contrib import admin
from django.contrib.auth.decorators import login_required

from lira.actions.dashboard import DashboardView
from lira.actions.document import CreateDocument
from lira.actions.document import DocumentList
from lira.actions.document import PictureList
from lira.actions.document import VideoList
from lira.actions.document import OtherList

from lira.actions.program import ProgramList
from lira.actions.program import ProgramUpdate
from lira.actions.program import ProgramNew
from lira.actions.program import ProgramDelete

from lira.actions.region import RegionList
from lira.actions.region import RegionNew
from lira.actions.region import RegionUpdate
from lira.actions.region import RegionDelete

from lira.actions.topic import TopicList
from lira.actions.topic import TopicNew
from lira.actions.topic import TopicUpdate
from lira.actions.topic import TopicDelete
from lira.views import site_index

from lira.authentication import StyledAuthForm

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', site_index, name='site_index'),
    url(r'^dashboard/$', DashboardView.as_view(), name='dashboard'),

    #Documents
    url(r'^manage/documents/new$', login_required(CreateDocument), name='new_document'),
    url(r'^manage/documents(/?)$', login_required(DocumentList.as_view()), name='documents'),
    url(r'^manage/pictures$', login_required(PictureList.as_view()), name='list_pictures'),
    url(r'^manage/videos$', VideoList.as_view(), name='list_videos'),
    url(r'^manage/others$', OtherList.as_view(), name='list_others'),

    # Programs
    url(r'^manage/programs/$', ProgramList.as_view(), name='list_programs'),
    url(r'^manage/programs(?P<page>[0-9]+)$', ProgramList.as_view(), name='list_programs'),
    url(r'^manage/programs/new$', ProgramNew.as_view(), name='new_program'),
    url(r'^manage/programs/update/(?P<pk>\d{1,10})$', ProgramUpdate.as_view(), name='update_program'),
    url(r'^manage/programs/delete/(?P<pk>\d{1,10})$', ProgramDelete.as_view(), name='delete_program'),

    # Regions
    url(r'^manage/regions/$', RegionList.as_view(), name='list_regions'),
    url(r'^manage/regions/new$', RegionNew.as_view(), name='new_region'),
    url(r'^manage/regions/update/(?P<pk>\d{1,10})$', RegionUpdate.as_view(), name='update_region'),
    url(r'^manage/regions/delete/(?P<pk>\d{1,10})$', RegionDelete.as_view(), name='delete_region'),

    # Topics
    url(r'^manage/topics/$', TopicList.as_view(), name='list_topics'),
    url(r'^manage/topics/new$', TopicNew.as_view(), name='new_topic'),
    url(r'^manage/topics/update/(?P<pk>\d{1,10})$', TopicUpdate.as_view(), name='update_topic'),
    url(r'^manage/topics/delete/(?P<pk>\d{1,10})$', TopicDelete.as_view(), name='delete_topic'),

    # Native admin UI
    url(r'^admin/', include(admin.site.urls)),
    url(r'^admin/jsi18n/', 'django.views.i18n.javascript_catalog'),

    # Login
    url(
        r'^accounts/login/$',
        'django.contrib.auth.views.login',
        { 'template_name': 'login/login.html', 'authentication_form': StyledAuthForm }
    ),
    url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'),

    # Language switcher
    url(r'^language/(?P<code>\w{2,3})$', 'mediabox.lira.views.set_language')
)
